package com.ruoyi.proSystem.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.proSystem.mapper.*;
import com.ruoyi.proSystem.service.IProInventoryService;
import com.ruoyi.proSystem.service.IProItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.proSystem.domain.ProProduct;
import com.ruoyi.proSystem.service.IProProductService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 用户首页展示Controller
 *
 * @author ruoyi
 * @date 2024-07-26
 */
@RestController
@RequestMapping("/proSystem")
public class ProProductController extends BaseController
{
    @Autowired
    private IProProductService proProductService;

    @Autowired
    private ProItemMapper proItemMapper;

    @Autowired
    private ProInventoryMapper proInventoryMapper;

    @Autowired
    ProExpressageMapper proExpressageMapper;

    @Autowired
    ProHtmlMapper proHtmlMapper;

@Autowired
    ProMarketingMapper proMarketingMapper;
@Autowired
            ProOtherConfigMapper proOtherConfigMapper;

    /**
     * 查询用户首页展示列表
     */
    @RequiresPermissions("proSystem:proSystem:list")
    @GetMapping("/list")
    public TableDataInfo list(ProProduct proProduct)
    {
        startPage();
        List<ProProduct> list = proProductService.selectProProductList(proProduct);
        return getDataTable(list);
    }

    /**
     * 导出用户首页展示列表
     */
    @RequiresPermissions("proSystem:proSystem:export")
    @Log(title = "用户首页展示", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProProduct proProduct)
    {
        List<ProProduct> list = proProductService.selectProProductList(proProduct);
        ExcelUtil<ProProduct> util = new ExcelUtil<ProProduct>(ProProduct.class);
        util.exportExcel(response, list, "用户首页展示数据");
    }

    /**
     * 获取用户首页展示详细信息
     */
    @RequiresPermissions("proSystem:proSystem:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(proProductService.selectProProductById(id));
    }

    /**
     * 新增用户首页展示
     */
    @RequiresPermissions("proSystem:proSystem:add")
    @Log(title = "用户首页展示", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProProduct proProduct)
    {
        System.out.println(proProduct);
        return toAjax(proProductService.insertProProduct(proProduct));
    }

    /**
     * 修改用户首页展示
     */
    @RequiresPermissions("proSystem:proSystem:edit")
    @Log(title = "用户首页展示", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProProduct proProduct)
    {
        return toAjax(proProductService.updateProProduct(proProduct));
    }

    /**
     * 删除用户首页展示
     */
    @RequiresPermissions("proSystem:proSystem:remove")
    @Log(title = "用户首页展示", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(proProductService.deleteProProductByIds(ids));
    }
}
